function main() {
    //程序入口
    require(["pluginAttach", "knockout"], function (pluginAttach, ko) {
        var vm = {
            firstName: ko.observable().extend({
                required: {
                    message: "请输入firstName",
                },
            }),

            lastName: ko
                .observable()
                .extend({
                    required: {
                        message: "请输入lastName",
                    },
                })
                .extend({
                    minLength: 2,
                    maxLength: 10,
                }),

            score: ko.observable().extend({
                validation: {
                    validator: function (val, params) {
                        //params 是下面定义的6，val是输入的值
                        if (val != null && val.length >= params) {
                            return true;
                        } else {
                            return false;
                        }
                    },
                    message: "最少要输入6位数字",
                    params: 6,
                },
            }),
            handleSubmit: function () {
                if (vm.errors().length == 0) {
                    //可以提交数据了.
                    // alert("submit success");
                    return true;
                } else {
                    // alert("submit failure");
                    vm.errors.showAllMessages();
                    return false;
                }
            },
        };

        vm.errors = ko.validation.group(vm);
        ko.applyBindings(vm, document.getElementById("root"));
    });
}
require(["../scripts/require.config"], main);
